package com.example.administrator.appstpremvpdemo.helper;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.appstpremvpdemo.R;

/**
 * @Author Administrator
 * @Date 2017/12/23
 * @description
 * @function
 */

public class StatusLayoutHelper {

    public static final int NO_NET = 0;
    public static final int LOAD_FAILD = 1;
    public static final int LOADING = 2;
    public static final int NO_DATA = 3;

    LayoutInflater mLayoutInflater;
    ViewGroup mContainer;

    public StatusLayoutHelper(ViewGroup container, LayoutInflater inflater) {
        this.mLayoutInflater = inflater;
        this.mContainer = container;
    }

    public View showNoNetlayout(int LayoutResId) {
        if (mLayoutInflater != null) {
            View view = mLayoutInflater.inflate(LayoutResId, null);
            return view;
        }
        return null;
    }

    public void showLoadfaildlayout() {

    }

    public void showLoadinglayout() {

    }

    public void showNoDatalayout() {

    }

    public void setDefaultLayoutType(int type) {

        View view;
        switch (type) {
        case NO_NET:
            view = showNoNetlayout(R.layout.defaultlayout_no_net);
            mContainer.addView(view);
            break;
        case LOAD_FAILD:
            view = showNoNetlayout(R.layout.defaultlayout_load_faild);
            mContainer.addView(view);
            break;
        case LOADING:
            view = showNoNetlayout(R.layout.defaultlayout_loading);
            mContainer.addView(view);
            break;
        case NO_DATA:
            view = showNoNetlayout(R.layout.defaultlayout_no_data);
            mContainer.addView(view);
            break;
        }
    }


    interface IStatusLayoutListner {
        void setInflater(LayoutInflater inflater);
    }
}

